import { Key } from 'react'
import { request } from '@/utils/http'
import type {
  IhospitalSetPrams,
  IhospitalSetsResponse,
  IAddHospitalItem,
} from './model/hospitalSetTypes'
import { IhospitalListItem } from './model/hospitalListTypes'

export function reqHospitalSets({
  page,
  limit,
  hosname,
  hoscode,
}: IhospitalSetPrams) {
  return request.get<any, IhospitalSetsResponse>(
    `/admin/hosp/hospitalSet/${page}/${limit}`,
    {
      params: {
        hosname,
        hoscode,
      },
    }
  )
}

export function reqAddHospitalSet(data: IAddHospitalItem) {
  return request.post<any, null>(`/admin/hosp/hospitalSet/save`, data)
}

export function reqGetHospitalSet(id: string) {
  return request.get<any, IhospitalListItem>(
    `/admin/hosp/hospitalSet/get/${id}`
  )
}

export function reqUpdateHospitalSet(data: IAddHospitalItem) {
  return request.put<any, null>(`/admin/hosp/hospitalSet/update`, data)
}

export function reqDeleteHospitalSetItem(id: number) {
  return request.delete<any, null>(`/admin/hosp/hospitalSet/remove/${id}`)
}

export function reqBatchDelHospitalSets(idList: Key[]) {
  return request.delete<any, null>(`/admin/hosp/hospitalSet/batchRemove`, {
    data: idList,
  })
}
